# -*- coding: utf-8 -*-
# @Time : 2022/2/24 9:00
# @Author : Administrator
# @Email : simple_days@qq.com
# @File : assetManageDao.py
# @Project : backend
# ©Copyright : 中国电建集团透平科技有限公司版权所有
from loguru import logger

from asset.utils.mongoDBManage import get_mongo_database

asset_database = get_mongo_database('pcttTest')
asset_collection = asset_database['assetv2']
def getAll():
    logger.info("查询所有资产信息")
    assetList = list(asset_collection.find({}, {'_id': 0}))
    logger.debug(assetList)
    total = len(assetList)
    logger.debug(f'获得的总数是{total}')
    return assetList, total

def addAsset(asset):
    logger.info("增加资产信息")
    # 资产型号
    product_id = asset['设备型号']
    # 资产类型
    type = asset['资产类型']
    # 资产数量
    number = asset['数量']
    # 厂商
    vendor = asset['厂商']
    # 生产年月
    product_date = asset['生产年月']




def updateAsset():
    pass

def deleteAsset():
    pass

def searchAsset():
    pass

def getYear():
    asset_database.command({"distinct":"assetv2","key":"年度"})